package options

import (
	"github.com/spf13/pflag"
)

type NacosOptions struct {
	Host      string `mapstructure:"host" json:"host"`
	Port      uint64 `mapstructure:"port" json:"port"`
	Namespace string `mapstructure:"namespace" json:"namespace"`
	User      string `mapstructure:"user" json:"user"`
	Password  string `mapstructure:"password" json:"password"`
	DataId    string `mapstructure:"dataid" json:"dataid"`
	Group     string `mapstructure:"group" json:"group"`
}

func NewNacosOptions() *NacosOptions {
	return &NacosOptions{
		Host:      "",
		Port:      0,
		Namespace: "",
		User:      "",
		Password:  "",
		DataId:    "",
		Group:     "",
	}
}

// Validate verifies flags passed to ServerOptions.
func (so *NacosOptions) Validate() []error {
	errs := []error{}
	return errs
}

// AddFlags adds flags related to server storage for a specific APIServer to the specified FlagSet.
// 命令行启动参数 配置
func (mo *NacosOptions) AddFlags(fs *pflag.FlagSet) {
	fs.StringVar(&mo.Host, "nacos.host", mo.Host, "nacos.host")
	fs.Uint64Var(&mo.Port, "nacos.port", mo.Port, "nacos.port")
	fs.StringVar(&mo.Namespace, "nacos.namespace", mo.Namespace, "nacos.namespace")
	fs.StringVar(&mo.User, "nacos.user", mo.User, "nacos.user")
	fs.StringVar(&mo.Password, "nacos.password", mo.Password, "nacos.password")
	fs.StringVar(&mo.DataId, "nacos.dataid", mo.DataId, "nacos.dataid")
	fs.StringVar(&mo.Group, "nacos.group", mo.Group, "nacos.group")
}
